import React, { Component } from 'react';


import { withRouter,NavLink} from 'react-router-dom';
import {observer,inject} from 'mobx-react';


@withRouter
@inject('first','two','observable','newStore')
@observer
class View extends Component {
    constructor(props){
        super(props)
        this.state = {
            name:'这是结果吗'
        }
    }
    getStore(){
        console.log(this.props.first)
        console.log(this.props.two)
        // this.props.first.testFn({test:1})
    }
    getMobx(){

        console.log(this.props.observable.total)
        console.log(this.props.observable.squared)
    }
    componentDidMount(){
        this.getStore();
        this.getMobx();
    }
    doAction(e){
        let {updateNameStr,} = this.props.observable;
        updateNameStr(this.state.name,'ssss')
    }
    getList(){
        let { baseInfo } = this.props.newStore;
        const lists = baseInfo.map((val,index)=>{
            return(
                <li key={val.id}>1111</li>
            )
        })
        return lists;
    }
    render(){
        // console.log(this.props.first.baseInfo.test)
        let {updateNameStr,objCfg,num} = this.props.observable;
        let {name} = this.props.newStore;
        let { baseInfo } = this.props.newStore;
        return(
            <React.Fragment>
            <NavLink to="/storepage">storepage</NavLink><br/>
            <NavLink to="/newstore">newstore</NavLink><br/>
            <br/>他的名字是{name}
                <div>1111</div>
                {objCfg.name}<br/>
                {num}<br/>
                <p>接受描述：<input type="button" onClick={(e)=>this.doAction(e)} value="点击改变"/></p>
                {baseInfo.length!==0 ? this.getList() : ''}
            </React.Fragment>
        )
    }
}




export default View;
